package com.yq.cp.service.yw.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.yq.cp.config.UserThreadLocal;
import com.yq.cp.entity.basics.Department;
import com.yq.cp.entity.basics.OrganizationalStructure;
import com.yq.cp.entity.basics.Position;
import com.yq.cp.entity.permission.User;
import com.yq.cp.entity.yw.YwYwfySq;
import com.yq.cp.entity.yw.YwYwfySqVo;
import com.yq.cp.entity.yw.dto.YwYwfySqDto;
import com.yq.cp.mapper.basics.DepartmentMapper;
import com.yq.cp.mapper.basics.OrganizationalStructureMapper;
import com.yq.cp.mapper.permission.UserMapper;
import com.yq.cp.mapper.yw.YwYwfySqMapper;
import com.yq.cp.service.basics.OrganizationalStructureService;
import com.yq.cp.service.basics.PositionService;
import com.yq.cp.service.yw.YwYwfySqService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yq.cp.utils.DateTimeUtil;
import com.yq.cp.utils.PdfPageUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 运维费用-申请 服务实现类
 * </p>
 *
 * @author zh
 * @since 2024-09-07
 */
@Service
@Transactional
public class YwYwfySqServiceImpl extends ServiceImpl<YwYwfySqMapper, YwYwfySq> implements YwYwfySqService {

    @Resource
    YwYwfySqMapper ywYwfySqMapper;
    @Resource
    DepartmentMapper departmentMapper;
    @Resource
    UserMapper userMapper;
    @Resource
    OrganizationalStructureMapper organizationalStructureMapper;

    @Resource
    PositionService positionService;
    @Override
    public void add(YwYwfySq ywYwfySq) {
//        ywYwfySq.setSqrId(UserThreadLocal.get().getId());
//        ywYwfySq.setSqrName(UserThreadLocal.get().getNickname());
        ywYwfySq.setFzrAuditState(0);
        ywYwfySq.setZzAuditState(0);
        ywYwfySq.setQxAuditState(0);

        Department department = departmentMapper.selectById(ywYwfySq.getSqbmId());
        if (department!=null){
            ywYwfySq.setSqbmName(department.getName());
        }
        ywYwfySq.setYear(DateTimeUtil.getYear());
        ywYwfySq.setMonth(DateTimeUtil.getMonth());

        ywYwfySqMapper.insert(ywYwfySq);
    }

    @Override
    public void audit1(YwYwfySq ywYwfySq) {
        YwYwfySq sq = ywYwfySqMapper.selectById(ywYwfySq.getId());
        sq.setFzrAuditState(ywYwfySq.getAuditState());
        sq.setFzrAuditTime(DateTimeUtil.dqsj());
        sq.setFzrAuditUserId(UserThreadLocal.get().getId());
        sq.setFzrAuditExcuse(ywYwfySq.getAuditExcuse());
        ywYwfySqMapper.updateById(sq);
    }
    @Override
    public void audit2(YwYwfySq ywYwfySq) {
        YwYwfySq sq = ywYwfySqMapper.selectById(ywYwfySq.getId());
        sq.setZzAuditState(ywYwfySq.getAuditState());
        sq.setZzAuditTime(DateTimeUtil.dqsj());
        sq.setZzAuditUserId(UserThreadLocal.get().getId());
        sq.setZzAuditExcuse(ywYwfySq.getAuditExcuse());
        ywYwfySqMapper.updateById(sq);
    }
    @Override
    public void audit3(YwYwfySq ywYwfySq) {
        YwYwfySq sq = ywYwfySqMapper.selectById(ywYwfySq.getId());
        sq.setQxAuditState(ywYwfySq.getAuditState());
        sq.setQxAuditTime(DateTimeUtil.dqsj());
        sq.setQxAuditUserId(UserThreadLocal.get().getId());
        sq.setQxAuditExcuse(ywYwfySq.getAuditExcuse());
        ywYwfySqMapper.updateById(sq);
    }

    @Override
    public IPage<YwYwfySq> page(YwYwfySqVo vo) {
        IPage<YwYwfySq> iPage=new Page<>(vo.getPage(),vo.getSize());

        vo.setSqbmId(UserThreadLocal.get().getDepartmentId());
        ywYwfySqMapper.page(iPage,vo);

        for (int i = 0; i < iPage.getRecords().size(); i++) {
            YwYwfySq ywYwfySq = iPage.getRecords().get(i);

            Long cxsfwfzr = userMapper.cxsfwfzr(ywYwfySq.getNyzId(), UserThreadLocal.get().getId());
            Long cxsfwzz = userMapper.cxsfwzz(ywYwfySq.getNyzId(), UserThreadLocal.get().getId());
            OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(ywYwfySq.getNyzId());



            Long cxsfwqx = userMapper.cxsfwqx(organizationalStructure.getParentId(), UserThreadLocal.get().getId());

            if (ywYwfySq.getFzrAuditState()==0){
                if (cxsfwfzr>0){
                    iPage.getRecords().get(i).setSfngsh(1);
                }else {
                    iPage.getRecords().get(i).setSfngsh(0);
                }
            }
            if (ywYwfySq.getFzrAuditState()==1 && ywYwfySq.getZzAuditState()==0){
                if (cxsfwzz>0){
                    iPage.getRecords().get(i).setSfngsh(1);
                }else {
                    iPage.getRecords().get(i).setSfngsh(0);
                }
            }
            if (ywYwfySq.getFzrAuditState()==1 && ywYwfySq.getZzAuditState()==1 && ywYwfySq.getQxAuditState()==0){
                if (cxsfwqx>0){
                    iPage.getRecords().get(i).setSfngsh(1);
                }else {
                    iPage.getRecords().get(i).setSfngsh(0);
                }
            }

            if (iPage.getRecords().get(i).getZzAuditUserZw()==null){
                iPage.getRecords().get(i).setZzAuditUserZw("站长");
            }
            if (iPage.getRecords().get(i).getQxAuditUserZw()==null){
                iPage.getRecords().get(i).setQxAuditUserZw("区县负责人");
            }
        }
        return iPage;
    }

    @Override
    public List<YwYwfySqDto> fytj(YwYwfySqVo vo) {
        List<YwYwfySqDto> fytj = ywYwfySqMapper.fytj(vo);
        return fytj;
    }

    @Override
    public BigDecimal fytjzj(YwYwfySqVo vo) {
        BigDecimal fytjzj = ywYwfySqMapper.fytjzj(vo);
        return fytjzj;
    }

    @Override
    public YwYwfySq get(Long id) {
        YwYwfySqVo vo=new YwYwfySqVo();
        vo.setId(id);
        IPage<YwYwfySq> page = page(vo);
        YwYwfySq ywYwfySq = page.getRecords().get(0);
        return ywYwfySq;
    }

    @Override
    public void getDaochu(YwYwfySq ywYwfySq, HttpServletResponse response) {
        User vo=new User();
        vo.setNickname(ywYwfySq.getSqrName());
        vo.setPhone(ywYwfySq.getPhone());
        User user = positionService.listUserToPosition(vo);
        // 定义全局的字体静态变量
        //定义全局字体静态变量
        Font titlefont;
        Font headfont = null;
        Font headfont1 = null;
        Font keyfont = null;
        Font textfont = null;
        Font textfont1 = null;
        Font content = null;
        Font space = null;
        Font space1 = null;
        Font space2 = null;
        Font space3 = null;
        // 最大宽度
        try {
            // 不同字体（这里定义为同一种字体：包含不同字号、不同style）
            BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            titlefont = new Font(font, 16, Font.BOLD);
            //四号
            headfont = new Font(font, 14, Font.BOLD);
            headfont1 = new Font(font, 14, Font.NORMAL);
            //三号
            content = new Font(font, 16, Font.NORMAL);
            //小四
            textfont = new Font(font, 11, Font.BOLD);
            textfont1 = new Font(font, 11, Font.NORMAL);
            space = new Font(font, 2, Font.NORMAL);
            space1 = new Font(font, 10, Font.NORMAL);
            space2 = new Font(font, 30, Font.NORMAL);
            space3 = new Font(font, 20, Font.NORMAL);
        } catch (Exception e) {
            e.printStackTrace();
        }
        BaseFont bf;
        Font font = null;
        try {
            //创建字体
            bf = BaseFont.createFont( "STSong-Light", "UniGB-UCS2-H",
                    BaseFont.NOT_EMBEDDED);
            //使用字体并给出颜色
            font = new Font(bf,20,Font.BOLD, BaseColor.BLACK);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Document document = new Document(new RectangleReadOnly(842F, 595F));
        //设置页边距  60:左边距，60：右边距，72：上边距，72：下边距
        document.setMargins(60, 60, 72, 72);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
            PdfPCell cell = null;
            //添加页码
            writer.setPageEvent(new PdfPageUtil());
            //打开生成的pdf文件
            document.open();



            //报警信息
            float[] widthes = {30f};
            PdfPTable tables = new PdfPTable(widthes);


            String aaa="aaa";


            widthes = new float[]{15f, 25f, 15f, 25f, 15f, 25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("申请人:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getSqrName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("申请人手机号:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getPhone(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);



            cell = new PdfPCell(new Paragraph("",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);



            cell = new PdfPCell(new Paragraph("",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);

            //未处理故障
            widthes = new float[]{10f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("申请人信息",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);


            widthes = new float[]{15f, 25f, 15f, 25f, 15f, 25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("所属渠道商:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(user.getQudaoshangName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("所属大区:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(user.getDaquName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("所属省级:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);


            cell = new PdfPCell(new Paragraph(user.getShengName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);




            widthes = new float[]{15f, 25f, 15f, 25f, 15f, 25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("所属市:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(user.getShiName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("所属区:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(user.getQuName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("所属能源站:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);


            cell = new PdfPCell(new Paragraph(user.getSiteName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);


            widthes = new float[]{15f, 25f, 15f, 25f, 15f, 25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("所属部门:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(user.getDepartmentName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("所属职位:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(user.getPositionName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);


            cell = new PdfPCell(new Paragraph("",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);



            widthes = new float[]{10f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("申请信息",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);



            widthes = new float[]{15f, 25f, 15f, 60f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("申请费用:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getFy()+"",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("申请事项:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getSqsx(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);




            widthes = new float[]{10f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("负责人审核信息",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);



            widthes = new float[]{15f, 25f, 15f, 25f, 15f, 25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("审核账号:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getFzrAuditUserName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("人员职位:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getFzrAuditUserZw(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);


            cell = new PdfPCell(new Paragraph("审核状态:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);
            switch (ywYwfySq.getFzrAuditState()){
                case 0:
                    aaa="审核中";
                    break;
                case 1:
                    aaa="审核通过";
                    break;
                case 2:
                    aaa="驳回";
                    break;
            }

            cell = new PdfPCell(new Paragraph(aaa,textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);


            widthes = new float[]{10f,25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("审核时间:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);


            cell = new PdfPCell(new Paragraph(DateTimeUtil.getStrDateTime(ywYwfySq.getFzrAuditTime()),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);


            widthes = new float[]{10f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("站长审核信息",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);



            widthes = new float[]{15f, 25f, 15f, 25f, 15f, 25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("审核账号:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getZzAuditUserName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("人员职位:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getZzAuditUserZw(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);


            switch (ywYwfySq.getZzAuditState()){
                case 0:
                    aaa="审核中";
                    break;
                case 1:
                    aaa="审核通过";
                    break;
                case 2:
                    aaa="驳回";
                    break;
            }
            cell = new PdfPCell(new Paragraph("审核状态:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(aaa,textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);


            widthes = new float[]{10f,25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("审核时间:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);




            cell = new PdfPCell(new Paragraph(DateTimeUtil.getStrDateTime(ywYwfySq.getZzAuditTime()),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);




            widthes = new float[]{10f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("区级审核信息",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);



            widthes = new float[]{15f, 25f, 15f, 25f, 15f, 25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);


            cell = new PdfPCell(new Paragraph("审核账号:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getQxAuditUserName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph("人员职位:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(ywYwfySq.getQxAuditUserZw(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            switch (ywYwfySq.getQxAuditState()){
                case 0:
                    aaa="审核中";
                    break;
                case 1:
                    aaa="审核通过";
                    break;
                case 2:
                    aaa="驳回";
                    break;
            }
            cell = new PdfPCell(new Paragraph("审核状态:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setBorder(0);
            cell.setFixedHeight(30);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(aaa,textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);


            widthes = new float[]{10f,25f};
            tables = new PdfPTable(widthes);
            tables.setSpacingBefore(10f);
            tables.setWidthPercentage(100.0f);

            cell = new PdfPCell(new Paragraph("审核时间:",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            cell = new PdfPCell(new Paragraph(DateTimeUtil.getStrDateTime(ywYwfySq.getQxAuditTime()),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setFixedHeight(30);
            cell.setBorder(0);
            tables.addCell(cell);

            document.add(tables);

            document.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
